﻿# coding:utf-8
import config_load

class UrlManager(object):
    def __init__(self):
        self.new_url_set = set()
        self.old_url_set = set()
    
    def add_new_url(self, new_url):
        if new_url is None or new_url in self.old_url_set:
            return 
        self.new_url_set.add(new_url)
    
    def add_new_urls(self, url_count,root_url):
        count = 1
        while count<=int(url_count):
            count = count + 1
            #print count
            tmp_url = root_url[:36] + str(count) + '/'
            #print tmp_url
            self.add_new_url(tmp_url)
        #print self.new_url_set
        
    def has_new_url(self):
        if self.new_url_set is None or len(self.new_url_set)==0:
            return False
        return True
    
    
    def get_new_url(self):
        new_url = self.new_url_set.pop()
        self.old_url_set.add(new_url)
        return new_url
    
